
from langchain_openai import ChatOpenAI
from langchain.schema import SystemMessage,HumanMessage,AIMessage
# 创建llm模型
def init_model() :
    # 模型定义
    ZHIPUAI_API_KEY = '794380a4cee054a0f96bb2844b41fd12.X4t70kph1CfmoKfT'
    BASE_PATH ='https://open.bigmodel.cn/api/paas/v4/'
    return ChatOpenAI(model_name='glm-4',temperature=.7,openai_api_key=ZHIPUAI_API_KEY,base_url=BASE_PATH)

llm = init_model()
res=llm.invoke( [HumanMessage('我喜欢吃西红柿，我应该吃什么') ]).content
print(res)